package pre.liuxl.blog.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pre.liuxl.blog.service.UserArticleService;

import javax.servlet.http.HttpSession;

/**
 * Created by liuxuanlong on 2018/6/16.
 */
@Controller
public class IndexController {
    private final static Logger logger = LoggerFactory.getLogger(IndexController.class);
    @Autowired
    UserArticleService userArticleService;

    @RequestMapping("/index")
    public String index(HttpSession session, Model model) {
        session.setAttribute("hottestArticle", userArticleService.findFirstFiveOrderByPraiseNum());
        model.addAttribute("articleList", userArticleService.findFirstTenOrderByCreateDate());
        return "index";
    }
}
